package chapter1;

/**
 * @Author juzipi
 * @Date 2021/5/10 17:01
 * @Info
 */
public class DeadThreadTest {

    public static void main(String[] args) {
        //简单的一个死循环实现了加锁的效果
        Runnable r = () -> {
            System.out.println(Thread.currentThread().getName() + "开始");
            DeadThread deadThread = new DeadThread();
            System.out.println(Thread.currentThread().getName() + "结束");
        };

        Thread thread1 = new Thread(r,"线程1");
        Thread thread2 = new Thread(r,"线程2");

        thread1.start();
        thread2.start();
    }


}

class DeadThread{
    static {
        if (true){
            System.out.println(Thread.currentThread().getName() + "初始化当前类");
            while (true){

            }
        }
    }
}
